import React, { useState } from 'react';
import type { MenuProps } from 'antd';
import { Menu } from 'antd';
import { Outlet, useNavigate } from 'react-router-dom';
// import { createBrowserHistory } from "history";
import './CorporateServices.scss'

interface Props { }
// var history = createBrowserHistory()

const items: MenuProps['items'] = [
    {
        label: '按热度分类',
        key: '/index/corporateServices/heatClassification',
    },
    {
        label: '按主题分类',
        key: '/index/corporateServices/subjectClassification',
    },
    {
        label: '按部门分类',
        key: '/index/corporateServices/departmentClassification',
    },
    {
        label: '最多跑一次',
        key: '/index/corporateServices/runOnce',
    },
];

function CorporateServices(props: Props) {
    var navigate = useNavigate();
    const [current, setCurrent] = useState('/index/corporateServices/heatClassification');

    const onClick: MenuProps['onClick'] = (e) => {
        console.log('click ', e);
        setCurrent(e.key);
        navigate(e.key);

    };
    return (
        <div className='corporateServices'>
            {/* 法人服务 */}
            <div className='corporateServices-top'>
                <div className='corporateServices-item'>法人服务</div>
                <Menu className='corporateServices-button' onClick={onClick} selectedKeys={[current]} mode="horizontal" items={items} />
            </div>
            <Outlet />
        </div>
    );
}

export default CorporateServices;